package dk.dashboardFP.elements.button {
	import dk.dashboardFP.panels.ui.text.DFPLabel;
	import dk.dashboardFP.uiElements.UIBack;

	import flash.display.MovieClip;
	import flash.display.Sprite;

	/**
	 * @author josef
	 */
	public class DFPButtonSubView extends Sprite {
		private var _sLabelText : String;
		private var _doLabel : DFPLabel;
		private var _doBackAsset : UIBack;
		private var _nMargin : Number = 5;
		private var _nHeightMargin : Number;

		public function DFPButtonSubView(sLabelText : String, nMargin:Number=5, nHeightMargin:Number=0) {
			
			_nHeightMargin = nHeightMargin;
			_nMargin = nMargin;
			_sLabelText = sLabelText;
			
			setupElements();
		}
		
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// on / off
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		
		public function setOn() : void {
			_doBackAsset.setOn();
		}
		
		public function setOff() : void {
			_doBackAsset.setOff();
		}

		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// setup
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

		private function setupElements() : void {
			
			//:::::::
			// label 
			_doLabel = new DFPLabel(_sLabelText, true);
			addChild(_doLabel);
			
			//:::::::
			// back 
			_doBackAsset = new UIBack();
			addChildAt(_doBackAsset, 0);
			
			//:::::::
			// back 
			
			_doBackAsset.width = _doLabel.width + 2 * _nMargin+1;
			_doBackAsset.height = _doLabel.height + 2 * _nHeightMargin;
			
			_doBackAsset.y = -2 - _nHeightMargin;
			
			_doLabel.x = _nMargin;
		}

		public function enable() : void {
			_doLabel.alpha=1;
		}

		public function disable() : void {
			_doLabel.alpha=0.3;
		}
	}
}
